package com.itguigu.process.controller;

import com.itguigu.common.result.Result;
import com.itguigu.model.process.ProcessTemplate;
import com.itguigu.process.service.ProcessTemplateService;
import com.itguigu.process.service.ProcessTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 审批流管理
 */
@Api(tags = "审批流管理")
@RestController
@Slf4j
@RequestMapping("/admin/process")
@CrossOrigin // 解决跨域注解
public class ProcessApiController {

    @Resource
    private ProcessTypeService processTypeService;

    @Resource
    private ProcessTemplateService processTemplateService;

    @ApiOperation(value = "获取全部审批分类及模板")
    @GetMapping("/findProcessType")
    public Result findProcessType() {
        log.info("获取全部审批分类及模板");
        return Result.success(processTypeService.findProcessType());
    }


    /**
     *  获取审批模板功能
     */
    @ApiOperation(value = "获取审批模板")
    @GetMapping("getProcessTemplate/{processTemplateId}")
    public Result get(@PathVariable Long processTemplateId) {
        log.info("要获取的审批模板的id : {} ", processTemplateId);
        ProcessTemplate processTemplate = processTemplateService.getById(processTemplateId);
        return Result.success(processTemplate);
    }

}
